package com.pattern.design.designpattern.Xiangyuan;

import java.util.HashMap;
import java.util.Map;

/**
 * author:harisucici on 2018/10/12 10:28
 * email:harisucici@gmail.com
 * name:
 * todo:
 */
public class TicketFactory {
    private static Map<String ,Ticket> map = new HashMap<>(2);


    /**
     * Get ticket ticket.
     *
     * @param start the start
     * @param end   the end
     * @return the ticket
     */
    public static Ticket getTicket(String start,String end){
        String key = start+"-"+end;
        if(map.containsKey(key)){
            return map.get(key);
        }else{
            TrainTicket trainTicket = new TrainTicket("beijing","tianjin");
            map.put(key,trainTicket);
            return trainTicket;
        }
    }
}
